package com.github.nuggets.service;


import com.github.nuggets.repository.AuthenticUserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * @description:
 * @author: wangsj
 * @date: 2022/3/15 7:02 下午
 */
@Service
public class AuthenticAccountDetailsService implements UserDetailsService {

    @Autowired
    AuthenticUserRepository authenticUserRepository;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        return authenticUserRepository.findByUsername(username)
                .orElseThrow(() -> new UsernameNotFoundException("未找到该用户:" + username));
    }
}
